﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace MessageWorkflow.Message
{
    public class WorkflowRequestAction<TResult> : WorkflowAction
    {
        private TResult _result;
        private bool _hasResult;

        public WorkflowRequestAction()
        {
        }

        /// <summary>
        /// Get the result. If assigned, this will also set the HasResult property
        /// </summary>
        public TResult Result
        {
            get { return _result; }
        }

        /// <summary>
        /// If true, Result has been set
        /// </summary>
        public bool HasResult { get { return _hasResult; } }

        /// <summary>
        /// Sets the result of the request and marks the action as complete
        /// </summary>
        public void SetResult(TResult value)
        {
            SetResult(value, true);
        }

        public void SetResult(TResult value, bool complete)
        {
            this.IsCompleted = complete;
            _hasResult = true;
            _result = value;
        }
    }
}
